<include file="Public/frame" />
<div class="content-wrap">
    <div class="hd cf place">&nbsp;&nbsp;&nbsp;购物车</div>
    <style type="text/css">
        table{
            border:1px solid #e9e9e9;
        }
        .head{
            border-bottom:1px solid #e9e9e9;
            line-height: 30px;
        }
        td{
            text-align: center;
        }
        .place{
           font-size: 16px;
            font-weight: bold;
            border-left: 2px solid #0084FF;
        }
    </style>
    <script type="text/javascript">

    function xiaojie(id,num,price){
        var xiaojie=$('#xiaojie'+id).val();
        return xiaojie=num * price;
    }

    function updateNum(id,price){
        var num=$('#num'+id).val();
        $.ajax({
            url:'{:U('User/Cart/updateCart')}',
            type:'POST',
            dataType:'json',
            data: 'num='+ num + "&id=" + id,
            success:function(data){
                if (data.status) {
                    popStatus(1, data.info, 1.5);
                    window.location.reload();
                }else{
                    popStatus(2, data.info, 1.5);
                }
            }
        });
    }
    </script>
    <div class="cart">
        <table width="100%" class="table-list">
        <thead>
            <tr class="head">
                <th width="45%">产品名称</th>
                <th width="10%">产品单价</th>
                <th width="20%">产品数量</th>
                <th width="10%">小    结</th>
                <th width="15%">操作</th>
            </tr>
        </thead>
        <tbody>
            <foreach name="carts" item="c">
                <tr>
                    <td>{$c['product_title']}</td>
                    <td>{$c['product_price']} <font color="red">￥</font></td>
                    <td><input id="num{$c['id']}" value="{$c['num']}" name="num" style="width:40px" type="text"> <input type="button" value="更新" onclick="updateNum({$c['id']},{$c['product_price']})" class="upbutton"></td>
                    <td><span id="xiaojie{$c['id']}"><script type="text/javascript">document.write(xiaojie({$c['id']},{$c['num']},{$c['product_price']}));</script></span> <font color="red">￥</font></td>
                    <td><a href="{:U('User/Order/index',array('id'=>$c['id']))}" target="_blank">去支付</a> <a href="{:U('User/Cart/del',array('id'=>$c['id']))}" target="_blank">删除</a></td>
                </tr>
            </foreach>
        </tbody>
        </table>
    </div>
    <div class="a5"></div>
</div>
<!--主要内容区-->

<!-- /主体 -->
<!-- 底部 -->
<include file="Public/foot" />